//
//  AddCarVinCell.m
//  saler-ios
//
//  Created by 王亚陆 on 17/9/12.
//  Copyright © 2017年 sayimba. All rights reserved.
//

#import "AddCarVinCell.h"

@implementation AddCarVinCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}


- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self){
        

        _field =[self createField:@"请输入车架号" andTag:1 andFont:FontOfSize13];
        _field.placeholder = @"请输入车架号";
//        LRViewBorderRadius(_field, 3, 0.5, AddCarNameBtnColor);

        [self.contentView addSubview:_field];
    }
    
    return self;
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}





-(CustomTextField*)createField:(NSString*)placeholder andTag:(NSInteger)tag andFont:(double)font{
    
    NSMutableAttributedString * placeH = [[NSMutableAttributedString alloc]initWithString:placeholder];
    
    CustomTextField * field =[[CustomTextField alloc]init];
    field.frame = CGRectMake(20*kWidth, 0, Main_Width-100*kWidth, 30*kWidth);
    field.delegate = self;
    field.font = Font(font);
    
    [field setValue:[UIFont boldSystemFontOfSize:font]forKeyPath:@"_placeholderLabel.font"];
    
    [placeH addAttribute:NSFontAttributeName
                   value:[UIFont boldSystemFontOfSize:16]
                   range:NSMakeRange(0, placeholder.length)];
    field.attributedPlaceholder = placeH;
    
    field.clearButtonMode = UITextFieldViewModeWhileEditing;
    field.userInteractionEnabled = YES;
    field.textAlignment = NSTextAlignmentLeft;
    field.returnKeyType = UIReturnKeyDone;
    CGFloat width = field.frame.size.width;
    CGFloat height = field.frame.size.height;
    //控制placeHolder的位置
    [field placeholderRectForBounds:CGRectMake(width/2, 0, width, height)];
    
    [field clearButtonRectForBounds:field.frame];
    
    return field;
}

@end
